/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-22 09:23:08
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-10-19 10:21:21
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\SampleReport.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'
export const SampleReport = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '样品检测报告',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST()['getSampleReportAttachment'],
        additional: { key: 'SampleUuid', value: 'uuid' },
        options: [
            Permission.findIndex(v => v.uuid === 'f39c340a-afa9-4f1c-b8cd-e398bde8b83a') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="上传检测报告"
                    ThrKey="ThrModal"
                    value="SampleReport"
                    data={data}
                />
            ),
        ],
        columns: [
            {
                dataIndex: 'SampleUuid',
                title: '报告uuid',
                valueType: 'hidden',
                hideInSearch: true,
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'originalName',
                title: '报告名称',
                valueType: 'hidden',
                search: false,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'createUserName',
                title: '上传人',
                valueType: 'hidden',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'createTime',
                title: '上传时间',
                valueType: 'hidden',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <SeeEnclosure
                            key="see"
                            data={{
                                className: 'Admin',
                                url: record.fileUrl,
                            }}
                        />,
                        Permission.findIndex(v => v.uuid === '57757faf-6112-4cf2-bb3a-e2ded83517df') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delSampleReportAttachment', title: '删除样品附件' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
